package buildtools;

import group.GeoGroup;

import java.util.ArrayList;
import java.util.List;

import node.GeoNode;

import component.AbstractComponent;
import component.Ball;
import component.Tube;
import component.group.ComponentGroup;

public class Extractor {
	
	public static ComponentGroup extractComponentGroup(GeoGroup group) {
		ComponentGroup list = new ComponentGroup();
		for (GeoNode node : group.getGeoNodes()) {
			list.add(node.getComponent());
		}
		return list;
	}

	public static List<Ball> extractBalls(ComponentGroup group) {
		List<Ball> list = new ArrayList<Ball>();
		for (AbstractComponent c : group.getComponents()) {
			if (c instanceof Ball)
				list.add((Ball)c);
		}
		return list;
	}
	
	public static List<Ball> extractBalls(GeoGroup group) {
		return extractBalls(extractComponentGroup(group));
	}
	
	public static List<Tube> extractTubes(ComponentGroup group) {
		List<Tube> list = new ArrayList<Tube>();
		for (AbstractComponent c : group.getComponents()) {
			if (c instanceof Tube)
				list.add((Tube)c);
		}
		return list;
	}
}
